﻿using Restaurant.DatabaseTools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Restaurant.entity
{
    class SData
    {
        public static List<Guestitem> Glistusing;
        public static DB db;
        public static Dictionary<int,string> table;//桌位的映射订单

       public static void init()
        {
            db = new DB("1.txt", "2.txt");
            Glistusing = new List<Guestitem>();
            table = new Dictionary<int, string>();
            for(int i=0;i<13;i++)
            {
                table.Add(i, "");
            }
        }

        public static void reInput()
        {
            db = new DB("1.txt", "2.txt");
        }

        public static void newGusing(string id, int guestn, string chargepeople, string remarks, double price, bool isroom, bool isstettle)
        {
            Guestitem git = new Guestitem();
            git.chargePeople = chargepeople;
            git.guestNum = guestn;
            git.isroom = isroom;
            git.price = price;
            git.remarks = remarks;
            git.itemlistNum = id;
            git.isSettlement = false;
            List<Menuitem> mlist = new List<Menuitem>();
            git.menuitems = mlist;
            Glistusing.Add(git);
        }
        public static void Modify_Gusing_charpeople(int index, string chargepeo)
        {
            Glistusing[index].chargePeople = chargepeo;
        }
        public static void Modify_Gusing(int index, int guestn, string chargepeople, string remarks, double price, bool isroom, bool isstettle)
        {
            Glistusing[index].chargePeople = chargepeople;
            Glistusing[index].guestNum = guestn;
            Glistusing[index].isroom = isroom;
            Glistusing[index].price = price;
            Glistusing[index].remarks = remarks;
        }

        public static void Del_Gusing(int index)
        {
            Glistusing[index].isSettlement = true;
        }

        public static  int Getindex(string id)//得到list 的项目的index
        {
            int index = -1;
            for (int i = 0; i < Glistusing.Count(); i++)
            {
                if (Glistusing[i].itemlistNum.Equals(id))
                {
                    index = i;
                }
            }
            return index;
        }


       
        
    }
}
